package com.tool.configuration.code.controller;

import com.tool.configuration.code.CheckCodeServlet1;
import com.tool.configuration.code.CheckCodeServlet2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/code")
public class CodeController {

    @GetMapping("/code1")
    public void testCode1(HttpServletRequest request, HttpServletResponse response) throws IOException {
        CheckCodeServlet1 codeServlet = new CheckCodeServlet1();
        try {
            codeServlet.doGet(request, response);
        } catch (ServletException e) {
            throw new RuntimeException(e);
        }
    }

    @GetMapping("/code2")
    public void testCode2(HttpServletRequest request, HttpServletResponse response) throws IOException {
        CheckCodeServlet2 codeServlet = new CheckCodeServlet2();
        try {
            codeServlet.doGet(request, response);
        } catch (ServletException e) {
            throw new RuntimeException(e);
        }
    }

}